<%-- Copyright (c) 2010 Canadensys --%>
<%-- JSP to handle Ajax call to suggest names (taxon, vernacular) --%>
<%@ page import="net.canadensys.dataportal.vascan.utils.Fulltext" %>
<%@ page import="java.util.Vector" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="org.json.*" %>
<%@ page import="net.canadensys.dataportal.utils.HibernateUtil" %>
<%@ include file="../_inc/functions.jsp" %>

<%
try{
	out.clear();
	org.hibernate.Session hibernateSession = HibernateUtil.getSessionFactory().getCurrentSession();
	hibernateSession.beginTransaction();
    JSONObject results = new JSONObject();
    String k = null;
    String l = null;
    if(request.getParameter("k") != null && request.getParameter("l") !=null){
        k = request.getParameter("k");
        l = request.getParameter("l");
        results = (JSONObject) Fulltext.searchLike(k,l,_bundle);
    }
    
    out.write(results.toString());
    hibernateSession.getTransaction().commit();
}
catch(Exception e){
    e.printStackTrace();
    out.write("{}");
}
%>